<?php

class DefaultController extends Controller
{
	public function actionIndex()
	{
        $categorys = NCategory::model()->findAll(array(
            'order' => 'ord desc'
        ));
		$this->render('index', array(
            'categorys' => $categorys
        ));
	}

    public function actionLogin()
    {
        $model = new LoginForm();
        if ($this->getPost('LoginForm')) {
            $model->attributes = $this->getPost('LoginForm');
            if ($model->validate() && $model->login()) {
                $this->redirect(Yii::app()->user->returnUrl);
            }
        }

        $this->renderPartial('login', array(
            'model' => $model
        ));
    }

    public function actionLogout()
    {
        Yii::app()->user->logout(false);
        $this->redirect(array('index'));
    }

    public function actionError()
    {
        echo 'error';
    }
}